package controllers;

import models.AppUser;
import models.UserRole;
import controllers.Secure.Security;
import play.mvc.Before;
import play.mvc.Controller;

public class CDR extends Controller {

	@Before
	static void setConnectedUser() {
		if (Authentication.isConnected()) {
			AppUser user = AppUser.find("login = ?", Authentication.connected())
					.first();
			renderArgs.put("user", user);
		}
	}

	@Before
	static void checkRights() {
		if (!Authentication.isConnected()
				|| !Authentication.check(UserRole.RECRUITMENT_MANAGER.name())) {
			error("Unauthorized access !");
		}
	}

	public static void area() {
		render();
	}
}
